home *** CD-ROM | disk | FTP | other *** search
- /*
- File: DeskBus.h
-
- Contains: Apple Desktop Bus (ADB) Interfaces.
-
- Version: Technology: System 7.5
- Release: Universal Interfaces 3.0d3 on Copland DR1
-
- Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
-
- Bugs?: If you find a problem with this file, send the file and version
- information (from above) and the problem description to:
-
- Internet: apple.bugs@applelink.apple.com
- AppleLink: APPLE.BUGS
-
- */
- #ifndef __DESKBUS__
- #define __DESKBUS__
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
- #ifndef __MIXEDMODE__
- #include <MixedMode.h>
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
- typedef SInt8 ADBAddress;
- /*
- This ProcPtr uses register based parameters on the 68k and cannot
- be written in or called from a high-level language without the help of
- mixed mode or assembly glue.
-
- typedef pascal void (*ADBCompletionProcPtr)(Ptr buffer, Ptr refCon, long command);
-
- */
- /*
- This ProcPtr uses register based parameters on the 68k and cannot
- be written in or called from a high-level language without the help of
- mixed mode or assembly glue.
-
- typedef pascal void (*ADBDeviceDriverProcPtr)(SInt8 devAddress, SInt8 devType);
-
- */
- /*
- This ProcPtr uses register based parameters on the 68k and cannot
- be written in or called from a high-level language without the help of
- mixed mode or assembly glue.
-
- typedef pascal void (*ADBServiceRoutineProcPtr)(Ptr buffer, ADBServiceRoutineUPP completionProc, Ptr refCon, long command);
-
- */
- /*
- This ProcPtr uses register based parameters on the 68k and cannot
- be written in or called from a high-level language without the help of
- mixed mode or assembly glue.
-
- typedef pascal void (*ADBInitProcPtr)(SInt8 callOrder);
-
- */
-
- #if GENERATINGCFM
- typedef UniversalProcPtr ADBCompletionUPP;
- typedef UniversalProcPtr ADBDeviceDriverUPP;
- typedef UniversalProcPtr ADBServiceRoutineUPP;
- typedef UniversalProcPtr ADBInitUPP;
- #else
- typedef Register68kProcPtr ADBCompletionUPP;
- typedef Register68kProcPtr ADBDeviceDriverUPP;
- typedef Register68kProcPtr ADBServiceRoutineUPP;
- typedef Register68kProcPtr ADBInitUPP;
- #endif
- struct ADBDataBlock {
- SInt8 devType; /* original handler ID */
- SInt8 origADBAddr; /* original ADB Address */
- ADBServiceRoutineUPP dbServiceRtPtr; /* service routine pointer */
- Ptr dbDataAreaAddr; /* this field is passed as the refCon parameter to the service routine */
- };
- typedef struct ADBDataBlock ADBDataBlock;
-
- typedef ADBDataBlock *ADBDBlkPtr;
- struct ADBSetInfoBlock {
- ADBServiceRoutineUPP siService; /* service routine pointer */
- Ptr siDataAreaAddr; /* this field is passed as the refCon parameter to the service routine */
- };
- typedef struct ADBSetInfoBlock ADBSetInfoBlock;
-
- typedef ADBSetInfoBlock *ADBSInfoPtr;
- /* ADBOpBlock is only used when calling ADBOp from 68k assembly code */
- struct ADBOpBlock {
- Ptr dataBuffPtr; /* buffer: pointer to variable length data buffer */
- ADBServiceRoutineUPP opServiceRtPtr; /* completionProc: completion routine pointer */
- Ptr opDataAreaPtr; /* refCon: this field is passed as the refCon parameter to the completion routine */
- };
- typedef struct ADBOpBlock ADBOpBlock;
-
- typedef ADBOpBlock *ADBOpBPtr;
- extern pascal void ADBReInit(void )
- ONEWORDINLINE(0xA07B);
-
- /*
- ADBOp has a different interface for 68k assembly than for everything else
- for 68k assembly the interface is
- #pragma parameter __D0 ADBOp(__A0,__D0)
- OSErr ADBOp( ADBOpBlock * pb, short commandNum );
- */
- /*
- IMPORTANT NOTE:
- "Inside Macintosh: Devices" documents the completion routine for ADBOp will be called with
- four parameters using 68k register based calling conventions, specifically the completion routine
- passed in should be of type ADBServiceRoutineProcPtr. However, when upp types were first added
- to this interface file, the type ADBCompletionUPP was mistakenly used for the second parameter
- to ADBOp. Since applications have shipped using completion routines of type ADBCompletionUPP,
- the mistake cannot be corrected.
- The only difference between ADBServiceRoutineUPP and ADBCompletionUPP is the former takes an extra
- argument which is a pointer to itself, fortunately not needed for PowerPC code.
- For compatibility with existing 68k code, when an ADBOp completion routine is called,
- 68k register A1 will point to the completion routine, as documented in Inside Mac.
- */
- extern pascal OSErr ADBOp(Ptr refCon, ADBCompletionUPP compRout, Ptr buffer, short commandNum);
-
-
- #if GENERATING68K && !GENERATINGCFM
- #pragma parameter __D0 CountADBs
- #endif
- extern pascal short CountADBs(void )
- ONEWORDINLINE(0xA077);
-
-
- #if GENERATING68K && !GENERATINGCFM
- #pragma parameter __D0 GetIndADB(__A0, __D0)
- #endif
- extern pascal ADBAddress GetIndADB(ADBDataBlock *info, short devTableIndex)
- ONEWORDINLINE(0xA078);
-
-
- #if GENERATING68K && !GENERATINGCFM
- #pragma parameter __D0 GetADBInfo(__A0, __D0)
- #endif
- extern pascal OSErr GetADBInfo(ADBDataBlock *info, ADBAddress adbAddr)
- ONEWORDINLINE(0xA079);
-
-
- #if GENERATING68K && !GENERATINGCFM
- #pragma parameter __D0 SetADBInfo(__A0, __D0)
- #endif
- extern pascal OSErr SetADBInfo(const ADBSetInfoBlock *info, ADBAddress adbAddr)
- ONEWORDINLINE(0xA07A);
-
-
- #if GENERATINGCFM
- #else
- #endif
-
- enum {
- uppADBCompletionProcInfo = kRegisterBased
- | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(Ptr)))
- | REGISTER_ROUTINE_PARAMETER(2, kRegisterA2, SIZE_CODE(sizeof(Ptr)))
- | REGISTER_ROUTINE_PARAMETER(3, kRegisterD0, SIZE_CODE(sizeof(long))),
- uppADBDeviceDriverProcInfo = kRegisterBased
- | REGISTER_ROUTINE_PARAMETER(1, kRegisterD0, SIZE_CODE(sizeof(SInt8)))
- | REGISTER_ROUTINE_PARAMETER(2, kRegisterD1, SIZE_CODE(sizeof(SInt8))),
- uppADBServiceRoutineProcInfo = kRegisterBased
- | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(Ptr)))
- | REGISTER_ROUTINE_PARAMETER(2, kRegisterA1, SIZE_CODE(sizeof(ADBServiceRoutineUPP)))
- | REGISTER_ROUTINE_PARAMETER(3, kRegisterA2, SIZE_CODE(sizeof(Ptr)))
- | REGISTER_ROUTINE_PARAMETER(4, kRegisterD0, SIZE_CODE(sizeof(long))),
- uppADBInitProcInfo = kRegisterBased
- | REGISTER_ROUTINE_PARAMETER(1, kRegisterD0, SIZE_CODE(sizeof(SInt8)))
- };
-
- #if GENERATINGCFM
- #define NewADBCompletionProc(userRoutine) \
- (ADBCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBCompletionProcInfo, GetCurrentArchitecture())
- #define NewADBDeviceDriverProc(userRoutine) \
- (ADBDeviceDriverUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBDeviceDriverProcInfo, GetCurrentArchitecture())
- #define NewADBServiceRoutineProc(userRoutine) \
- (ADBServiceRoutineUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBServiceRoutineProcInfo, GetCurrentArchitecture())
- #define NewADBInitProc(userRoutine) \
- (ADBInitUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBInitProcInfo, GetCurrentArchitecture())
- #else
- #define NewADBCompletionProc(userRoutine) \
- ((ADBCompletionUPP) (userRoutine))
- #define NewADBDeviceDriverProc(userRoutine) \
- ((ADBDeviceDriverUPP) (userRoutine))
- #define NewADBServiceRoutineProc(userRoutine) \
- ((ADBServiceRoutineUPP) (userRoutine))
- #define NewADBInitProc(userRoutine) \
- ((ADBInitUPP) (userRoutine))
- #endif
-
- #if GENERATINGCFM
- #define CallADBCompletionProc(userRoutine, buffer, refCon, command) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppADBCompletionProcInfo, (buffer), (refCon), (command))
- #define CallADBDeviceDriverProc(userRoutine, devAddress, devType) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppADBDeviceDriverProcInfo, (devAddress), (devType))
- #define CallADBServiceRoutineProc(userRoutine, buffer, completionProc, refCon, command) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppADBServiceRoutineProcInfo, (buffer), (completionProc), (refCon), (command))
- #define CallADBInitProc(userRoutine, callOrder) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppADBInitProcInfo, (callOrder))
- #else
- /* (*ADBCompletionUPP) cannot be called from a high-level language without the Mixed Mode Manager */
- /* (*ADBDeviceDriverUPP) cannot be called from a high-level language without the Mixed Mode Manager */
- /* (*ADBServiceRoutineUPP) cannot be called from a high-level language without the Mixed Mode Manager */
- /* (*ADBInitUPP) cannot be called from a high-level language without the Mixed Mode Manager */
- #endif
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __DESKBUS__ */
-
-